package interview;

public class interview_10_05 {
    public int findString(String[] words, String s) {
        int len=words.length;
        int l=0;
        int r=len-1;
        while(l<=r){
            while(l<=r&&words[l].equals("")) l++;
            while(l<=r&&words[r].equals("")) r--;
            int mid=l+(r-l)/2;
            while(mid<=r&&words[mid].equals("")) mid++;
//       while(mid>=l&&words[mid].equals("")) mid--;
            if(words[mid].compareTo(s)==0){
                return mid;
            }
            if(words[mid].compareTo(s)>0){
                r=mid-1;
            }else{
                l=mid+1;
            }
        }
        return -1;
    }
}
